import { createSlice } from '@reduxjs/toolkit';

export const snackbarSlice = createSlice({
  name: 'snackbar',
  initialState: {
    value: {
      open: false,
      message: '',
      autoHideDuration: 3000,
      severity: 'success',
      anchorOrigin: {
        vertical: 'top',
        horizontal: 'left',
      },
    },
  },
  reducers: {
    change: (state, action) => {
      state.value = {
        ...state.value,
        ...action.payload,
      };
    },
  },
});

export const { change } = snackbarSlice.actions;

export default snackbarSlice.reducer;
